package com.zggk.lzz.seach2;

import android.app.Activity;

import com.alibaba.fastjson.JSON;
import com.zggk.lzz.api.MyApplication;
import com.zggk.lzz.api.Urls;
import com.zggk.lzz.callback.StringDialogCallback;
import com.zggk.lzz.mvp.BasePresenterImpl;
import com.lzy.okgo.OkGo;
import com.lzy.okgo.model.Response;

/**
 * MVPPlugin
 *  邮箱 784787081@qq.com
 */

public class Seach2Presenter extends BasePresenterImpl<Seach2Contract.View> implements Seach2Contract.Presenter{
    @Override
    public void getData(String param, Activity activity) {
        OkGo.<String>post(Urls.JAVASERVER+"pms/rhms/lzzapp/getEnentInfoByParam")
                .params("token", "Bearer$" + MyApplication.spUtils.getString("Token",""))
                .params("param", param)
                .execute(new StringDialogCallback(activity) {
                    @Override
                    public void onSuccess(Response<String> response) {
                        Seach2Bean seach2Bean = JSON.parseObject(response.body(),Seach2Bean.class);
                        if (mView == null)
                            return;
                        if (seach2Bean.getCode().equals("200")){
                            mView.getDatas(seach2Bean.getData());
                        }else {
                            mView.onRequestError(seach2Bean.getMessage());
                        }
                    }
                });
    }
}
